 package com.mo.lib.utils.data

import android.text.TextUtils

/**
 * @ author：mo
 * @ data：2021/10/18:9:30
 * @ 功能：
 */
fun isSpace(s: String?): Boolean {
    if (TextUtils.isEmpty(s)) return true
    var i = 0
    val len = s!!.length
    while (i < len) {
        if (!Character.isWhitespace(s[i])) {
            return false
        }
        ++i
    }
    return true
}

/** double保留小数点后几位,默认保留两位*/
fun String.getString(size: Int = 2) = String.format("%." + size + "f", this)
 fun Number.getString(size: Int = 2)=this.toString().getString(size)

/** 字符串是否为空*/
fun isEmpty(str: String?)= str == null || TextUtils.isEmpty(str) || str == "\n" || str == "\t" || TextUtils.isEmpty(str.trim { it <= ' ' }) || str.isEmpty() || "" == str || "null" == str
